import cv2
import numpy as np


image=cv2.imread("C:\\Users\\20436\Desktop\huanghua.jpg")
hsv_image=cv2.cvtColor(
    image,
    cv2.COLOR_BGR2HSV
)
yellow_low=np.array([20,100,100])
yellow_high=np.array([30,255,255])
mask=cv2.inRange(
    hsv_image,
    yellow_low,
    yellow_high
)
green_low=np.array([35,40,40])
green_high=np.array([85,255,255])
mask1=cv2.inRange(
    hsv_image,
    green_low,
    green_high
)
mask_zong=cv2.bitwise_or(mask,mask1)

noise_image=cv2.medianBlur(
    image,
    91
)
result = image.copy()
result[mask_zong == 0] = noise_image[mask_zong == 0]

cv2.imshow("result",result)
cv2.imwrite('result.jpg',result)
cv2.waitKey(0)
